import http from '@/api/http.js'
import checkPayWay from '@/utils/mp_checkPayWay.js'
import toutiaoPay from '@/utils/pay.toutiao.js'
import zhifubaoPay from '@/utils/pay.zhifubao.js'

const orderpay = function(orderData,successFun='',failFun = '') {
	let ordersn = orderData.ordersn,
		orderid = orderData.orderid,
		pageType = orderData.pageType ? orderData.pageType : 0; // 页面跳转模式 默认0为直接跳转 1为关闭当前页面跳转
	// #ifdef H5
	// 前往支付页面
	if(pageType == 1)
	{ // 为关闭当前页面跳转
		uni.redirectTo({
			url: `/platforms/h5/pay/index?ordersn=${ordersn}`
		})
	}
	else
	{ // 直接跳转
		uni.navigateTo({
			url: `/platforms/h5/pay/index?ordersn=${ordersn}`
		})	
	}
	// #endif

	// #ifdef MP-WEIXIN
	checkPayWay(orderData, successFun, failFun)
	// #endif
	
	// #ifdef MP-TOUTIAO
	toutiaoPay(orderData,successFun,failFun)
	// #endif
	// #ifdef MP-ALIPAY
	zhifubaoPay(orderData,successFun,failFun)
	// #endif
	
	// #ifdef APP-PLUS
	// 前往支付页面
	if(pageType == 1)
	{ // 为关闭当前页面跳转
		uni.redirectTo({
			url: `/platforms/app-plus/pay/index?ordersn=${ordersn}`
		})
	}
	else
	{ // 直接跳转
		uni.navigateTo({
			url: `/platforms/app-plus/pay/index?ordersn=${ordersn}`
		})	
	}
	// #endif
	
}

export default orderpay
